package com.aabte.springcloudlearn.configclientdemo.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * {@link RefreshScope} 注解可以实现动态刷新这个Controller的Bean
 *
 * @author Daniel
 */
@Slf4j
@RestController
@RefreshScope
@RequestMapping("/api")
public class TestController {

    @Value("${from}")
    private String fromValue;

    @GetMapping(value = "/from")
    public String returnFromValue() {
        log.info("Start returnFromValue. fromValue: {}", fromValue);
        return fromValue;
    }

}
